#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int Judge(int year)
{
	if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0)
		return 1;
	else
		return 0;

}

int main()
{
	int year = 0;
	int month = 0;
	int day = 0;
	scanf("%d %d %d", &year, &month, &day);
	int arr1[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
	int arr2[12] = { 31,29,31,30,31,30,31,31,30,31,30,31 };

	if (1 == Judge(year))
	{
		for (int i = 0; i < month - 1; i++)
		{
			day += arr2[i];

		}
	}
	else
	{
		for (int i = 0; i < month - 1; i++)
		{
			day += arr1[i];
		}
	}
	printf("%d", day);

	return 0;
}